\(\int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx\) [1451]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [F]
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 21, antiderivative size = 94 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=-a^2 x-\frac {3 b^2 x}{2}+\frac {2 a b \cos (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {a^2 \tan (c+d x)}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {b^2 \sin ^2(c+d x) \tan (c+d x)}{2 d} \]

[Out]

-a^2*x-3/2*b^2*x+2*a*b*cos(d*x+c)/d+2*a*b*sec(d*x+c)/d+a^2*tan(d*x+c)/d+3/2*b^2*tan(d*x+c)/d-1/2*b^2*sin(d*x+c
)^2*tan(d*x+c)/d

Rubi [A] (verified)

Time = 0.10 (sec) , antiderivative size = 94, normalized size of antiderivative = 1.00, number of steps used = 11, number of rules used = 9, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.429, Rules used = {2801, 3554, 8, 2670, 14, 2671, 294, 327, 209} \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=\frac {a^2 \tan (c+d x)}{d}+a^2 (-x)+\frac {2 a b \cos (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {b^2 \sin ^2(c+d x) \tan (c+d x)}{2 d}-\frac {3 b^2 x}{2} \]

[In]

Int[(a + b*Sin[c + d*x])^2*Tan[c + d*x]^2,x]

[Out]

-(a^2*x) - (3*b^2*x)/2 + (2*a*b*Cos[c + d*x])/d + (2*a*b*Sec[c + d*x])/d + (a^2*Tan[c + d*x])/d + (3*b^2*Tan[c
 + d*x])/(2*d) - (b^2*Sin[c + d*x]^2*Tan[c + d*x])/(2*d)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 14

Int[(u_)*((c_.)*(x_))^(m_.), x_Symbol] :> Int[ExpandIntegrand[(c*x)^m*u, x], x] /; FreeQ[{c, m}, x] && SumQ[u]
 &&  !LinearQ[u, x] &&  !MatchQ[u, (a_) + (b_.)*(v_) /; FreeQ[{a, b}, x] && InverseFunctionQ[v]]

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 294

Int[((c_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^
n)^(p + 1)/(b*n*(p + 1))), x] - Dist[c^n*((m - n + 1)/(b*n*(p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^(p + 1), x
], x] /; FreeQ[{a, b, c}, x] && IGtQ[n, 0] && LtQ[p, -1] && GtQ[m + 1, n] &&  !ILtQ[(m + n*(p + 1) + 1)/n, 0]
&& IntBinomialQ[a, b, c, n, m, p, x]

Rule 327

Int[((c_.)*(x_))^(m_)*((a_) + (b_.)*(x_)^(n_))^(p_), x_Symbol] :> Simp[c^(n - 1)*(c*x)^(m - n + 1)*((a + b*x^n
)^(p + 1)/(b*(m + n*p + 1))), x] - Dist[a*c^n*((m - n + 1)/(b*(m + n*p + 1))), Int[(c*x)^(m - n)*(a + b*x^n)^p
, x], x] /; FreeQ[{a, b, c, p}, x] && IGtQ[n, 0] && GtQ[m, n - 1] && NeQ[m + n*p + 1, 0] && IntBinomialQ[a, b,
 c, n, m, p, x]

Rule 2670

Int[sin[(e_.) + (f_.)*(x_)]^(m_.)*tan[(e_.) + (f_.)*(x_)]^(n_.), x_Symbol] :> Dist[-f^(-1), Subst[Int[(1 - x^2
)^((m + n - 1)/2)/x^n, x], x, Cos[e + f*x]], x] /; FreeQ[{e, f}, x] && IntegersQ[m, n, (m + n - 1)/2]

Rule 2671

Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((b_.)*tan[(e_.) + (f_.)*(x_)])^(n_.), x_Symbol] :> With[{ff = FreeFactors[Ta
n[e + f*x], x]}, Dist[b*(ff/f), Subst[Int[(ff*x)^(m + n)/(b^2 + ff^2*x^2)^(m/2 + 1), x], x, b*(Tan[e + f*x]/ff
)], x]] /; FreeQ[{b, e, f, n}, x] && IntegerQ[m/2]

Rule 2801

Int[((a_) + (b_.)*sin[(e_.) + (f_.)*(x_)])^(m_.)*((g_.)*tan[(e_.) + (f_.)*(x_)])^(p_.), x_Symbol] :> Int[Expan
dIntegrand[(g*Tan[e + f*x])^p, (a + b*Sin[e + f*x])^m, x], x] /; FreeQ[{a, b, e, f, g, p}, x] && NeQ[a^2 - b^2
, 0] && IGtQ[m, 0]

Rule 3554

Int[((b_.)*tan[(c_.) + (d_.)*(x_)])^(n_), x_Symbol] :> Simp[b*((b*Tan[c + d*x])^(n - 1)/(d*(n - 1))), x] - Dis
t[b^2, Int[(b*Tan[c + d*x])^(n - 2), x], x] /; FreeQ[{b, c, d}, x] && GtQ[n, 1]

Rubi steps \begin{align*} \text {integral}& = \int \left (a^2 \tan ^2(c+d x)+2 a b \sin (c+d x) \tan ^2(c+d x)+b^2 \sin ^2(c+d x) \tan ^2(c+d x)\right ) \, dx \\ & = a^2 \int \tan ^2(c+d x) \, dx+(2 a b) \int \sin (c+d x) \tan ^2(c+d x) \, dx+b^2 \int \sin ^2(c+d x) \tan ^2(c+d x) \, dx \\ & = \frac {a^2 \tan (c+d x)}{d}-a^2 \int 1 \, dx-\frac {(2 a b) \text {Subst}\left (\int \frac {1-x^2}{x^2} \, dx,x,\cos (c+d x)\right )}{d}+\frac {b^2 \text {Subst}\left (\int \frac {x^4}{\left (1+x^2\right )^2} \, dx,x,\tan (c+d x)\right )}{d} \\ & = -a^2 x+\frac {a^2 \tan (c+d x)}{d}-\frac {b^2 \sin ^2(c+d x) \tan (c+d x)}{2 d}-\frac {(2 a b) \text {Subst}\left (\int \left (-1+\frac {1}{x^2}\right ) \, dx,x,\cos (c+d x)\right )}{d}+\frac {\left (3 b^2\right ) \text {Subst}\left (\int \frac {x^2}{1+x^2} \, dx,x,\tan (c+d x)\right )}{2 d} \\ & = -a^2 x+\frac {2 a b \cos (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {a^2 \tan (c+d x)}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {b^2 \sin ^2(c+d x) \tan (c+d x)}{2 d}-\frac {\left (3 b^2\right ) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (c+d x)\right )}{2 d} \\ & = -a^2 x-\frac {3 b^2 x}{2}+\frac {2 a b \cos (c+d x)}{d}+\frac {2 a b \sec (c+d x)}{d}+\frac {a^2 \tan (c+d x)}{d}+\frac {3 b^2 \tan (c+d x)}{2 d}-\frac {b^2 \sin ^2(c+d x) \tan (c+d x)}{2 d} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.24 (sec) , antiderivative size = 77, normalized size of antiderivative = 0.82 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=\frac {-4 \left (2 a^2+3 b^2\right ) (c+d x)+b \sec (c+d x) (24 a+8 a \cos (2 (c+d x))+b \sin (3 (c+d x)))+\left (8 a^2+9 b^2\right ) \tan (c+d x)}{8 d} \]

[In]

Integrate[(a + b*Sin[c + d*x])^2*Tan[c + d*x]^2,x]

[Out]

(-4*(2*a^2 + 3*b^2)*(c + d*x) + b*Sec[c + d*x]*(24*a + 8*a*Cos[2*(c + d*x)] + b*Sin[3*(c + d*x)]) + (8*a^2 + 9
*b^2)*Tan[c + d*x])/(8*d)

Maple [A] (verified)

Time = 0.66 (sec) , antiderivative size = 89, normalized size of antiderivative = 0.95

method result size
parallelrisch \(\frac {8 a b \cos \left (2 d x +2 c \right )+b^{2} \sin \left (3 d x +3 c \right )+\left (-8 a^{2} d x -12 b^{2} d x +32 a b \right ) \cos \left (d x +c \right )+\left (8 a^{2}+9 b^{2}\right ) \sin \left (d x +c \right )+24 a b}{8 d \cos \left (d x +c \right )}\) \(89\)
derivativedivides \(\frac {a^{2} \left (\tan \left (d x +c \right )-d x -c \right )+2 a b \left (\frac {\sin ^{4}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (2+\sin ^{2}\left (d x +c \right )\right ) \cos \left (d x +c \right )\right )+b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (\sin ^{3}\left (d x +c \right )+\frac {3 \sin \left (d x +c \right )}{2}\right ) \cos \left (d x +c \right )-\frac {3 d x}{2}-\frac {3 c}{2}\right )}{d}\) \(116\)
default \(\frac {a^{2} \left (\tan \left (d x +c \right )-d x -c \right )+2 a b \left (\frac {\sin ^{4}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (2+\sin ^{2}\left (d x +c \right )\right ) \cos \left (d x +c \right )\right )+b^{2} \left (\frac {\sin ^{5}\left (d x +c \right )}{\cos \left (d x +c \right )}+\left (\sin ^{3}\left (d x +c \right )+\frac {3 \sin \left (d x +c \right )}{2}\right ) \cos \left (d x +c \right )-\frac {3 d x}{2}-\frac {3 c}{2}\right )}{d}\) \(116\)
risch \(-a^{2} x -\frac {3 b^{2} x}{2}-\frac {i {\mathrm e}^{2 i \left (d x +c \right )} b^{2}}{8 d}+\frac {a b \,{\mathrm e}^{i \left (d x +c \right )}}{d}+\frac {a b \,{\mathrm e}^{-i \left (d x +c \right )}}{d}+\frac {i {\mathrm e}^{-2 i \left (d x +c \right )} b^{2}}{8 d}+\frac {2 i a^{2}+2 i b^{2}+4 a b \,{\mathrm e}^{i \left (d x +c \right )}}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )}\) \(124\)
norman \(\frac {\left (a^{2}+\frac {3 b^{2}}{2}\right ) x +\left (-a^{2}-\frac {3 b^{2}}{2}\right ) x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (-a^{2}-\frac {3 b^{2}}{2}\right ) x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+\left (a^{2}+\frac {3 b^{2}}{2}\right ) x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-\frac {8 a b}{d}-\frac {2 \left (2 a^{2}+b^{2}\right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {\left (2 a^{2}+3 b^{2}\right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}-\frac {\left (2 a^{2}+3 b^{2}\right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {8 a b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}}{\left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )^{2} \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}\) \(216\)

[In]

int(sec(d*x+c)^2*sin(d*x+c)^2*(a+b*sin(d*x+c))^2,x,method=_RETURNVERBOSE)

[Out]

1/8*(8*a*b*cos(2*d*x+2*c)+b^2*sin(3*d*x+3*c)+(-8*a^2*d*x-12*b^2*d*x+32*a*b)*cos(d*x+c)+(8*a^2+9*b^2)*sin(d*x+c
)+24*a*b)/d/cos(d*x+c)

Fricas [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 81, normalized size of antiderivative = 0.86 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=-\frac {{\left (2 \, a^{2} + 3 \, b^{2}\right )} d x \cos \left (d x + c\right ) - 4 \, a b \cos \left (d x + c\right )^{2} - 4 \, a b - {\left (b^{2} \cos \left (d x + c\right )^{2} + 2 \, a^{2} + 2 \, b^{2}\right )} \sin \left (d x + c\right )}{2 \, d \cos \left (d x + c\right )} \]

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*((2*a^2 + 3*b^2)*d*x*cos(d*x + c) - 4*a*b*cos(d*x + c)^2 - 4*a*b - (b^2*cos(d*x + c)^2 + 2*a^2 + 2*b^2)*s
in(d*x + c))/(d*cos(d*x + c))

Sympy [F]

\[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=\int \left (a + b \sin {\left (c + d x \right )}\right )^{2} \sin ^{2}{\left (c + d x \right )} \sec ^{2}{\left (c + d x \right )}\, dx \]

[In]

integrate(sec(d*x+c)**2*sin(d*x+c)**2*(a+b*sin(d*x+c))**2,x)

[Out]

Integral((a + b*sin(c + d*x))**2*sin(c + d*x)**2*sec(c + d*x)**2, x)

Maxima [A] (verification not implemented)

none

Time = 0.27 (sec) , antiderivative size = 83, normalized size of antiderivative = 0.88 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=-\frac {2 \, {\left (d x + c - \tan \left (d x + c\right )\right )} a^{2} + {\left (3 \, d x + 3 \, c - \frac {\tan \left (d x + c\right )}{\tan \left (d x + c\right )^{2} + 1} - 2 \, \tan \left (d x + c\right )\right )} b^{2} - 4 \, a b {\left (\frac {1}{\cos \left (d x + c\right )} + \cos \left (d x + c\right )\right )}}{2 \, d} \]

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/2*(2*(d*x + c - tan(d*x + c))*a^2 + (3*d*x + 3*c - tan(d*x + c)/(tan(d*x + c)^2 + 1) - 2*tan(d*x + c))*b^2
- 4*a*b*(1/cos(d*x + c) + cos(d*x + c)))/d

Giac [A] (verification not implemented)

none

Time = 0.40 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.46 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=-\frac {{\left (2 \, a^{2} + 3 \, b^{2}\right )} {\left (d x + c\right )} + \frac {4 \, {\left (a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 2 \, a b\right )}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1} + \frac {2 \, {\left (b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 4 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 4 \, a b\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1\right )}^{2}}}{2 \, d} \]

[In]

integrate(sec(d*x+c)^2*sin(d*x+c)^2*(a+b*sin(d*x+c))^2,x, algorithm="giac")

[Out]

-1/2*((2*a^2 + 3*b^2)*(d*x + c) + 4*(a^2*tan(1/2*d*x + 1/2*c) + b^2*tan(1/2*d*x + 1/2*c) + 2*a*b)/(tan(1/2*d*x
 + 1/2*c)^2 - 1) + 2*(b^2*tan(1/2*d*x + 1/2*c)^3 - 4*a*b*tan(1/2*d*x + 1/2*c)^2 - b^2*tan(1/2*d*x + 1/2*c) - 4
*a*b)/(tan(1/2*d*x + 1/2*c)^2 + 1)^2)/d

Mupad [B] (verification not implemented)

Time = 17.04 (sec) , antiderivative size = 145, normalized size of antiderivative = 1.54 \[ \int (a+b \sin (c+d x))^2 \tan ^2(c+d x) \, dx=\frac {\left (2\,a^2+3\,b^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+\left (4\,a^2+2\,b^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3+8\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+\left (2\,a^2+3\,b^2\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+8\,a\,b}{d\,\left (-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}-x\,\left (a^2+\frac {3\,b^2}{2}\right ) \]

[In]

int((sin(c + d*x)^2*(a + b*sin(c + d*x))^2)/cos(c + d*x)^2,x)

[Out]

(8*a*b + tan(c/2 + (d*x)/2)^3*(4*a^2 + 2*b^2) + tan(c/2 + (d*x)/2)^5*(2*a^2 + 3*b^2) + tan(c/2 + (d*x)/2)*(2*a
^2 + 3*b^2) + 8*a*b*tan(c/2 + (d*x)/2)^2)/(d*(tan(c/2 + (d*x)/2)^2 - tan(c/2 + (d*x)/2)^4 - tan(c/2 + (d*x)/2)
^6 + 1)) - x*(a^2 + (3*b^2)/2)